package main

import (
	"fmt"

	"golang.org/x/crypto/bcrypt"
)

func main() {
	// 慢速加盐算法
	hashed, err := bcrypt.GenerateFromPassword([]byte("123@456"), 4)
	fmt.Println(string(hashed), err)

	// hashed1 := "$2a$10$tmrQLx/isCSHEyJFmj2X4eXWVtZa.n.ie4hTLp8EE42ke6DzNFRFO"
	// hashed2 := "$2a$16$AIhw0PetgfNS5jDxTISxsut.C8V5qQ2pTYocdCeDcpClRm/9kc84i"

	err = bcrypt.CompareHashAndPassword(hashed, []byte("123@456"))
	fmt.Println(err)

	// err = bcrypt.CompareHashAndPassword([]byte(hashed1), []byte("123@456"))
	// fmt.Println(err)
	// // hashed2 := "$2a$16$AIhw0PetgfNS5jDxTISxsut.C8V5qQ2pTYocdCeDcpClRm/9kc84i"
	// err = bcrypt.CompareHashAndPassword([]byte(hashed2), []byte("123@456"))
	// fmt.Println(err)

}
